<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />

<#include "lib/lib.html" />
<title>商户管理</title>
</head>
<body style="background-color: #F0F0F0">
	<nav class="breadcrumb">
	 	 <i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 合作渠道商管理 <span class="c-gray en">&gt;</span> 商户管理
		 <a  class="btn btn-success radius r mr-20"  style="line-height: 1.6em; margin-top: 3px" href="javascript:location.replace(location.href);" title="刷新">
		 <i class="Hui-iconfont">&#xe68f;</i></a>
	</nav>
	<div class="pd-20 ">
		<div class="panel panel-default" >
			<div class="panel-header" style="height: 30px;">
				<div class="fl" style="font-size: 15px;">条件筛选</div>
				<div class="r">
					<!-- <button name="" id="" class="btn btn-success" type="submit"> <i class="Hui-iconfont"></i> 搜索 </button> -->
					<button class="layui-btn layui-btn-small" onclick="data_form_submit()"><i class="layui-icon" style="line-height:12px;">&#xe615;</i>搜索</button>
					<button class="layui-btn layui-btn-small" onclick="exportExcel()"><i class="layui-icon" style="line-height: 12px;">&#xe601;</i>导出</button>
				</div>
			</div>
			<div class="panel-body">
				<div class="">
			        <form action="" method="post" id="comForm">

			        	<div class="layui-row">
						    <div class="layui-col-xs3">
						      <div class="grid-demo grid-demo-bg1">
						      	搜关键字：<input type="text" id="companyName" name="companyName" value="${map.companyName}" placeholder=	"输入商户名称或商户帐号模糊检索" style="width: 270px" class="input-text">
						      </div>
						    </div>
						    <div class="layui-col-xs3">
						      <div class="grid-demo grid-demo-bg1">
						      	商户号：<input type="text" id="companyKey" name="companyKey" value="${map.companyKey}" placeholder=	"输入商户号精确查询" style="width: 270px" class="input-text">
						      </div>
						    </div>
						    <div class="layui-col-xs3">
						      <div class="grid-demo">
						      	渠道商：<select class="select" style="width: 80px" name="channelId" id="channelId">
										<option value="">全部</option>
										<#if payv2ChannelList?? && payv2ChannelList?size gt 0>
										<#list payv2ChannelList as dl >
											<option value="${dl.id}" <#if dl.id==map.channelId>selected="selected"</#if>>${dl.channelName}</option>
										</#list>
										</#if>
							</select>
						      </div>
						    </div>
						    <div class="layui-col-xs3">
						      <div class="grid-demo grid-demo-bg1">
						      	商户状态：<select class="select" datatype="*" id="companyStatus" name="companyStatus" nullmsg="请选择！" style="width: 80px">
									<option value="">全部</option>
				        	 		<option value="1" <#if map.companyStatus==1> selected="selected" </#if>>未审核</option>
				        	 		<option value="2" <#if map.companyStatus==2> selected="selected" </#if>>通过</option>
				        	 		<option value="3" <#if map.companyStatus==3> selected="selected" </#if>>未通过</option>
				        	 		<option value="4" <#if map.companyStatus==4> selected="selected" </#if>>终止合作</option>
			        			</select>
						      </div>
						    </div>
						</div>
		        	 		
					<!-- <input id="resetButton" class="btn" type="button" value="清空"></input> -->
					
					</form>
				</div>
			</div>
		</div>
		<div class="panel panel-default mt-20">
			<div class="panel-header" style="height:25px;">
				<div class="fl" style="font-size: 15px;">商户列表</div>
			</div>
			<div class="panel-body">
				<div id="page" class="holder"></div>  
				<table class="table table-border table-bordered table-hover table-bg table-sort">
					<thead>
						<tr class="text-c">
							<th width="40">商户帐号</th>
							<!-- <th width="40">商户ID</th> -->
							<th width="150">商户名称</th>
							<th width="80">商户号</th>
							<th width="150">所属渠道商</th>
							<th width="100">账户类型</th>
							<th width="100">联行号</th>
							<th width="150">开户支行</th>
							<th width="80">业务员</th>
							<!-- <th width="100">支付通道(个)</th> -->
							<th width="50">商户状态</th>
							<th width="100">创建时间</th>
							<th width="300">操作</th>
						</tr>
					</thead>
					<tbody>
						<#if list.dataList?? && list.dataList?size gt 0>
						<#list list.dataList as dl >
							<tr class="text-c">
								<!-- <td>${dl_index+1}</td> -->
								<td>${dl.userName!}</td>
								<td>${dl.companyName}</td>
								<td>${dl.companyKey}</td>
								<td>${dl.channelName}</td>
								<td>
								<#if dl.accountType==1>企业对公</#if>
								<#if dl.accountType==2>法人对私</#if>
								<#if dl.accountType==3>非法人对私</#if>
								</td>
								<td>${dl.coupletNumber}</td>
								<td>${dl.accountBank}</td>
								<td>${dl.saleName}</td>
								<td>
								<#if dl.companyStatus==1><span class="label-warning radius">待审核</span></#if>
								<#if dl.companyStatus==2><span class="badge-success radius">通过</span></#if>
								<#if dl.companyStatus==3><span class="label-danger radius">未通过</span></#if>
								<#if dl.companyStatus==4><span class="badge-danger radius">终止合作</span></#if>
								</td>
								<td>
									<#if dl.createTime??>
										${dl.createTime?string("yyyy-MM-dd")}
									</#if>
								</td>
								<td class="td-manage">
									<#if dl.companyStatus==1>
										<!-- <a style="text-decoration:none" onClick="handle('${dl.id!}','2','审核通过','')" href="javascript:;" title="审核通过"><i class="Hui-iconfont">&#xe63c;</i></a> -->
										<!-- <a title="审核" href="javascript:;"  onclick="company_view_handle('审核','${basePath}/payv2BussCompany/companyHandleView.do?companyId='+${dl.id!},1200);"  class="ml-5" style="text-decoration:none"><i class="Hui-iconfont edit-btn">审核通过</i></a> -->
										<a title="审核" href="javascript:;"  onclick="company_view_detail('审核商户 —— ${dl.companyName!}','${basePath}/payv2BussCompany/viewDetail.do?type=1&id='+${dl.id!},800,600);"  class="ml-5" style="text-decoration:none"><i class="Hui-iconfont edit-btn">审核商户</i></a>
										<!-- <i class="Hui-iconfont">|</i>
										<a style="text-decoration:none" onClick="handle('${dl.id!}','3','审核失败','${basePath}/payv2BussCompany/toApprove.do?id=${dl.id}')" href="javascript:;" title="审核失败"><i class="Hui-iconfont">&#xe6dd;</i></a> --> 
									</#if>
									<#if dl.companyStatus==2>
										<!-- <a title="查看" href="javascript:;"  onclick="company_edit('编辑商户','${basePath}/payv2BussCompany/toViewPayv2BussCompany.do?id='+${dl.id!},1000);"  class="ml-5" style="text-decoration:none"><i class="Hui-iconfont edit-btn">查看</i></a> -->
										<a title="查看" href="javascript:;"  onclick="company_view_detail('查看商户 —— ${dl.companyName!}','${basePath}/payv2BussCompany/viewDetail.do?type=1&id='+${dl.id!},800,600);"  class="ml-5" style="text-decoration:none"><i class="Hui-iconfont edit-btn">查看</i></a>
										<#if switchType==2>
											<a title="配置通道" href="javascript:;"  onclick="company_view_config('配置通道 —— ${dl.companyName!}','${basePath}/payv2BussCompany/configPayWayRateV2.do?id='+${dl.id!},1000,600);"  class="ml-5" style="text-decoration:none"><i class="Hui-iconfont edit-btn">配置通道</i></a>
										</#if>
										<i class="Hui-iconfont">|</i>
										<!-- <a title="支付通道" href="javascript:;"  onclick="getSupportPayWayList('支付通道','${basePath}/Payv2BussSupportPayWay/getSupportPayWayList.do?payWayStatus=0&parentId='+${dl.id!},1400);"  class="ml-5" style="text-decoration:none"><i class="Hui-iconfont edit-btn">支付通道</i></a> -->
										<a title="查看订单" href="${basePath}/Payv2PayOrder/getPayv2PayOrderList.do?companyId=${dl.id!}"    class="ml-5" style="text-decoration:none"><i class="Hui-iconfont edit-btn">查看订单</i></a>
										<a title="终止合作" onClick="handleOever('${dl.id!}','2','终止合作','')" href="javascript:;"  class="ml-5 badge-danger radius" style="text-decoration:none"><i class="Hui-iconfont">终止合作</i></a>
									</#if>
									<#if dl.companyStatus==3>
										<a title="查看原因" href="javascript:;"  onclick="reviewFailReason('${dl.companyPassReason!}')"  class="ml-5" style="text-decoration:none"><i class="Hui-iconfont edit-btn">查看原因</i></a>
									</#if>
									<#if dl.companyStatus==4>
										<a style="text-decoration:none" onClick="handleRecovery('${dl.id!}','2','恢复合作','')" href="javascript:;" title="恢复合作"><i class="Hui-iconfont label-success radius">恢复合作</i></a> 
										<a title="查看订单" href="${basePath}/Payv2PayOrder/getPayv2PayOrderList.do?companyId=${dl.id!}"  class="ml-5" style="text-decoration:none"><i class="Hui-iconfont edit-btn">查看订单</i></a>
										<a style="text-decoration:none" onClick="deleteCompany('${dl.id!}','1','删除','')" href="javascript:;" title="删除"><i class="Hui-iconfont badge-danger radius">删除</i></a>
									</#if>
								</td>
							</tr>
						</#list>
						</#if>
					</tbody>
				</table>
				</br>
				<div id="page_list" class="text-c"></div>
			</div>
		</div>
		
		
	</div>
	<script type="text/javascript">
		


		function data_form_submit(){
			$("#comForm").attr("action","${basePath}/payv2BussCompany/companyList.do").submit();
		}

		$(function(){
		 	$("#resetButton").bind("click", function(){
		 		$("#companyName").val("");
		 		$("#channelId").val("");
		 		$("#licenseType").val("");
		 		$("#companyScale").val("");
		 		$("#companyRangeProvince").val("");
		 		$("#companyRangeCity").val("");
		 		$("#companyStatus").val("");
		 	});
		});
	
		layui.use(['laypage', 'layer'], function(){
	  		var laypage = layui.laypage,layer = layui.layer;
			laypage.render({
			    elem: 'page_list',	//容器。值支持id名、原生dom对象，jquery对象
			    count: ${list.totalData!'0'},	//数据总数。一般通过服务端得到
			    //groups: 5,	//连续出现的页码个数
			    limit: ${list.pageData!'10'},
			    limits: [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],
				curr: ${list.curPage!'1'}, //获取起始页
			    layout: ['count', 'prev', 'page', 'next', 'limit', 'skip'],
			    jump: function(obj, first){
			      if (!first) {
			      	window.location.href="${basePath}/payv2BussCompany/companyList.do?curPage="+obj.curr +"&pageData="+obj.limit 	+ "&companyName=" + $("#companyName").val()
			      	      		 + "&channelId=" + $("#channelId").val()
		 	         			 + "&companyKey=" + $("#companyKey").val()
		 	    		 		 + "&companyStatus=" + $("#companyStatus").val();
					}
			    }
			  });
		});
		var isChange = 0;
		$(document).ready(function(){
			$('select').searchableSelect();
			isChange++;
		})
	// 	$(function(){
	// 	 	laypage({
	// 	 	    cont: $('.page_list'), //容器。值支持id名、原生dom对象，jquery对象,
	// 		    pages: ${list.endPage! }, //总页数
	// 	 	    //skip: true, //是否开启跳页
	// // 	    	skin: 'molv',
	// 	 	    groups: 10, //连续显示分页数
	// 	 	    first: '首页', //若不显示，设置false即可
	// 	 	    last: '尾页', //若不显示，设置false即可
	// 	 	    curr:${list.curPage!},
	// 	 	   	hash: true, //开启hash
	// 	 	    skin: '#00AA91',
	// 	 	    jump: function(obj,first){ //触发分页后的回调
	// 	 	    	if(!first){
	// 	 	         	 window.location.href="${basePath}/payv2BussCompany/companyList.do?curPage="+obj.curr +"&pageData="+10
	// 	 	         			 + "&companyName=" + $("#companyName").val()
	// 	 	         			 + "&channelId=" + $("#channelId").val()
	// 	 	         			 + "&licenseType=" + $("#licenseType").val()
	// 	 	         			 + "&companyScale=" + $("#companyScale").val()
	// 	 	    		 		 + "&companyRangeProvince=" + $("#companyRangeProvince").val()
	// 	 	    		 		 + "&companyRangeCity=" + $("#companyRangeCity").val()
	// 	 	    		 		 + "&companyStatus=" + $("#companyStatus").val();
	// 	 	    	}
	// 	 	    }
	// 	 	});
		 			
	// 	});
		
		function reviewFailReason(reason) {
			layer.open({
			  title: '审核失败原因'
			  ,content: ''+reason
			});   
		}
		
		function cityChange(proId,cityId){
			if(isChange==0){
				return;
			}else{
				$("#companyRangeCity").empty();
				var pro = $("#"+proId).val();
				$("#"+cityId).empty();
				if(pro==""){
					$("#"+cityId).append('<option value="">市</option>');
				}else{
					$.ajax({
						type:"get",
						url:"${basePath}/payv2BussCompany/proCity.do?parentId="+pro,
						async:true,
						success:function(data){
							if(!!data&&data.resultCode==200){
								var list = data.Data,
									str="";
								for(var i=0;i<list.length;i++){
									str+='<option value="'+list[i].id+'">'+list[i].name+'</option>'
								}
								$("#"+cityId).append(str);
								$(".city .searchable-select").remove();
	            				$("#"+cityId).searchableSelect();
							}else{
								alert(data.message);
							}
						}
					});
				}
			}
		}

		//查看支付通道
		function getSupportPayWayList(title,url,w,h){
				layer_show(title, url, w, h);
		}
		//查看订单
		function getPayv2PayOrderList(title,url,w,h){
				layer_show(title, url, w, h);
		}
		//管理商铺
		function payv2BussCompanyShopList(title,url,w,h){
				layer_show(title, url, w, h);
		}
		//查看APP列表
		function goApp(title,url,w,h){
				layer_show(title, url, w, h);
		}
		
		/*查看*/
		function company_edit(title,url,w,h){
			layer_show(title, url, w, h);
		}
		/*查看原因*/
		function company_view(title,url,w,h){
			layer_show(title, url, w, h);
		}
		/* 审核通过(显示商户资料页面 在下方有一个按钮通过或拒绝) */
		function company_view_handle(title,url,w,h){
			layer_show(title, url, w, h);
		}
		/* 查看商户详情 */
		function company_view_detail(title,url,w,h){
			layer_show(title, url, w, h);
		}
		
		/* 配置商户通道 */
		function company_view_config(title,url,w,h){
			layer_show(title, url, w, h);
		}
		
		/* 审核通过 */
		function handle(id,status,tips,url){
			if(status==2){
				layer.confirm("确认要"+ tips +"吗？", function(index) {
					var data = {};
					data.id = id;
					data.companyStatus = 2;
					//后台请求保存数据
					$.axse("${basePath}/payv2BussCompany/approveAgreePayv2BussCompany.do",  data, function(d){
						console.info(d);
						if(d.resultCode == 200){
							layer.msg('已审核,其中不包含不在审核期的订单哦!', {
								icon : 1,
								time : 1000
							});
							location.replace(location.href);
						}else{
							Huimodal_alert("审核失败,请重试!",1500);
						}
					},
					function(d){
						Huimodal_alert("审核失败,服务器异常!",1500);
					});
				});
			}else if(status==3){
				layer_show("审核", url, 800, 500);
			}
		}
		//删除
		function deleteCompany(id,status,tips,url){
			if(status==1){
				layer.confirm("确认要"+ tips +"吗？", function(index) {
					var data = {};
					data.id = id;
					data.isDelete = status;
					//后台请求保存数据
					$.axse("${basePath}/payv2BussCompany/updatePayv2BussCompany.do",  data, function(d){
						if(d.resultCode == 200){
							layer.msg('删除成功!', {
								icon : 1,
								time : 1000
							});
							location.replace(location.href);
						}else{
							Huimodal_alert("审核失败,请重试!",1500);
						}
					},
					function(d){
						Huimodal_alert("审核失败,服务器异常!",1500);
					});
				});
			}else if(status==3){
				layer_show("删除", url, 800, 500);
			}
		}
		//恢复合作
		function handleRecovery(id,status,tips,url){
			if(status==2){
				layer.confirm("确认要"+ tips +"吗？", function(index) {
					var data = {};
					data.id = id;
					data.companyStatus = 2;
					//后台请求保存数据
					$.axse("${basePath}/payv2BussCompany/updatePayv2BussCompany.do",  data, function(d){
						if(d.resultCode == 200){
							layer.msg('恢复合作成功!', {
								icon : 1,
								time : 1000
							});
							location.replace(location.href);
						}else{
							Huimodal_alert("审核失败,请重试!",1500);
						}
					},
					function(d){
						Huimodal_alert("审核失败,服务器异常!",1500);
					});
				});
			}else if(status==3){
				layer_show("审核", url, 800, 500);
			}
		}
		
		/* 终止合作 */
		function handleOever(id,status,tips,url){
			if(status==2){
				layer.confirm("确认要"+ tips +"吗？", function(index) {
					var data = {};
					data.id = id;
					data.companyStatus = 4;
					//后台请求保存数据
					$.axse("${basePath}/payv2BussCompany/updatePayv2BussCompany.do",  data, function(d){
						if(d.resultCode == 200){
							layer.msg('终止合作成功!', {
								icon : 1,
								time : 1000
							});
							location.replace(location.href);
						}else{
							Huimodal_alert("审核失败,请重试!",1500);
						}
					},
					function(d){
						Huimodal_alert("审核失败,服务器异常!",1500);
					});
				});
			}else if(status==3){
				layer_show("审核", url, 800, 500);
			}
		}
		
		function exportExcel(){
			$("#comForm").attr('action', '/payv2BussCompany/exportExcel.do');
			$("#comForm").submit();
			$("#comForm").attr('action', '/payv2BussCompany/companyList.do');
		}
		function addCode(companyId){
			var data = {};
			data.id = companyId;
			$.axse("${basePath}/bussComapnyCode/addCode.do",  data, function(data){
				if(data.resultCode == 200){
					layer.msg('添加成功!', {
						icon : 1,
						time : 1000
					});
				}else if(data.resultCode == 201){
					layer.alert('该商户收款码已存在', {
					  icon: 2,
					  skin: 'layer-ext-moon' //该皮肤由layer.seaning.com友情扩展。关于皮肤的扩展规则，去这里查阅
					})
				}else{
					layer.msg('添加失败，请联系技术!', {
						icon : 2,
						time : 1000
					});
				}
			})
		}
		$(document).keypress(function(e) {			
		   	// 回车键事件  
		      if(e.which == 13) {  
		  		jQuery(".confirmButton").click();
		  		data_form_submit()
		      }  
		});
	</script>
</body>
</html>